<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>View All Companies</title>
	<f:metadata>
		  <f:viewParam name="init" value="#{viewAllCompaniesBean.viewParameterInit}"/>
	</f:metadata>
</h:head>

<h:body>

	<h:form prependId="false">

		<p:messages id="messages" showDetail="true" autoUpdate="true" />
		
		<p:commandButton value="Fetch list of all companies" action="#{viewAllCompaniesBean.fetchAll}" update="mainTable"/>

		<p:dataTable 
			id="mainTable" style="margin-top:20px; margin-bottom:50px;" widgetVar="companyDataTableWidget"
			var="company" value="#{viewAllCompaniesBean.listOfCompanies}" 
			paginator="true" rows="10" 
		    currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {JumpToPageDropdown} "
			rowsPerPageTemplate="5,10,15" paginatorPosition="bottom" sortBy="#{company.companyCode}" sortOrder="DESCENDING"
			
		>
		
		        
        	<p:column >
				 <h:outputLink ajax="false" immediate="true" includeViewParams="true" value="#{request.contextPath}/pages/admin/companies/view.xhtml?code=#{company.companyCode}&amp;init=true" >
					<h:outputText value="View and Configure"/>
					<!-- <h:graphicImage value="/images/icons/view.gif" style="border:0;margin:0px;"/>  -->
				</h:outputLink> 
	<!-- 			
				<p:commandButton id="viewButton" value="View" icon="ui-icon-search"  style="font-size:60%"/>
	 -->			
			</p:column> 
		
			<p:column id="companyNameColumn" filterBy="#{company.companyName}" filterMatchMode="startsWith" sortBy="#{company.companyName}" >
	            <f:facet name="header">
    	            <h:outputText value="Company Name" />
            	</f:facet>
            	<h:outputText value="#{company.companyName}"/>
        	</p:column>

			<p:column id="companyCodeColumn" filterBy="#{company.companyCode}" filterMatchMode="startsWith" sortBy="#{company.companyCode}" >
	            <f:facet name="header">
    	            <h:outputText value="Company Code" />
            	</f:facet>
            	<h:outputText value="#{company.companyCode}"/>
        	</p:column>

			<p:column id="companyCityColumn"  sortBy="#{company.companyCity}">
	            <f:facet name="header">
    	            <h:outputText value="Company City" />
            	</f:facet>
            	<h:outputText value="#{company.companyCity}"/>
        	</p:column>

			<p:column id="companyCountryColumn"  sortBy="#{company.companyCountry}">
	            <f:facet name="header">
    	            <h:outputText value="Company Country" />
            	</f:facet>
            	<h:outputText value="#{company.companyCountry}"/>
        	</p:column>

			<p:column id="companyIdColumn"  >
	            <f:facet name="header">
    	            <h:outputText value="Company Id" />
            	</f:facet>
            	<h:outputText value="#{company.id}"/>
        	</p:column>
			 	
		</p:dataTable>
		
	</h:form>
</h:body>
</html>